var show_day = new Array('星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日');
var time = new Date();
var day = time.getDay();
document.getElementById('sj').innerHTML = time.toLocaleString();
setInterval("document.getElementById('sj').innerHTML=new Date().toLocaleString()", 1000);
document.getElementById('xq').innerHTML = show_day[day - 1];
$(window).load(function () {
    $('#slider').nivoSlider({controlNavThumbs: true});
});
$(function () {
    setJd();
});
function setJd() {
    var _width = $('.num').text();//获取百分比数值
    $('.main').css('width', _width);//将数值赋值给main的width
}
var tout;
$("#grzx").hover(function () {
    clearTimeout(tout);
    $(this).show();
}, function () {
    $(this).show();
});
$("#grz").hover(function () {
    $("#grzx").show()
}, function () {
    tout = setTimeout(function () {
        $("#grzx").hide()
    }, 300);
});
$("#tab_menu_friend").click(function () {
    $("#xgtp").show();
    $("#list").hide();
    $("#cx").hide();
});
$("#tab_menu_friend1").click(function () {
    $("#cx").show();
    $("#xgtp").hide();
    $("#list").hide();
});
$("#tab_menu_care").click(function () {
    $("#xgtp").hide();
    $("#list").show();
    $("#cx").hide();
})

var fr = new FileReader();
$("#tp2").change(function () {
    fr.readAsDataURL(this.files[0]);
})
fr.onload = function () {
    $("#img1").attr("src", this.result)
}
$("#nc").blur(function () {
    $("#nickname1").html($(this).val());
});
$("#btn").click(function () {
    var data2 = new FormData($('#f2')[0]);
    $.ajax({
        url: '/update_userinfo',
        type: 'POST',
        data: data2,
        success: function (o) {
            alert(o);
            location.reload(true);
        },
        processData: false,
        contentType: false
    });
    return false;
});
$(function () {
    $.ajax({
        url: "/get_session",
        type: 'GET',
        success: function (o) {
            var user = JSON.parse(o);
            console.log(user["icon"]);
            if (user["icon"] != "") {
                document.getElementById("icon").src = user["icon"];
                document.getElementById("img1").src = user["icon"];
                document.getElementById("nickname1").innerHTML = user["nickname"];
                document.getElementById("nickname").innerHTML = user["nickname"];
                document.getElementById("img11").src = user["icon"];
                document.getElementById("nc1").innerHTML = user["nickname"];
                document.getElementById("sex1").innerHTML = user["sex"];
                document.getElementById("age1").innerHTML = user["age"];
                document.getElementById("phone1").innerHTML = user["phone"];
            }
            if (o != "") {
                $("#cg").hide();
                $("#jr").show();
            }
        }
    })
});


